/*
 *          PassThrough.glsl
 *
 */

//------------------------------------------------------------------------------


-- Vertex


// IN
layout(location = 0) in vec4 inPosition;
layout(location = 1) in vec3 inNormal;
layout(location = 2) in vec2 inTexCoord;

out vec3 vNormal;
out vec2 vTexCoord;

// UNIFORM
uniform mat4 uModelViewProjMatrix;


void main()
{
  gl_Position = uModelViewProjMatrix * inPosition;
  vNormal = inNormal;
  vTexCoord = inTexCoord;
}


--

//------------------------------------------------------------------------------


-- Fragment

// IN
in vec3 vNormal;
in vec2 vTexCoord;

// OUT
layout(location = 0) out vec4 fragColor;

// UNIFORM
uniform sampler2D uDiffuseMap;
uniform vec3 uDiffuseColor;
uniform vec3 uLightDir;
uniform bool uEnableTexturing = false;
uniform bool uEnableLighting  = false;

void main()
{
  vec3 color = uDiffuseColor;
  
  if (uEnableTexturing) {
    color = texture( uDiffuseMap, vTexCoord).rgb;
  }
  
  if (uEnableLighting) {
    color *= max( 0.1f, dot( normalize(-uLightDir), vNormal));
  }
  
  fragColor = vec4( color, 1.0f);
}

